package com.easydev.mq.rabbit.pool;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import com.easydev.mq.rabbit.RabbitMQConfig;

public class PoolConfig extends GenericObjectPoolConfig {

    public PoolConfig() {
        setMaxTotal(RabbitMQConfig.POOL_NUM); // 整个池最大值
        setBlockWhenExhausted(true);
        setMaxWaitMillis(-1); // 获取不到永远等待
        setNumTestsPerEvictionRun(Integer.MAX_VALUE); // always test all idle objects
        setTestOnBorrow(true);
        setTestOnReturn(false);
        setTestWhileIdle(false);
        setTimeBetweenEvictionRunsMillis(1 * 60000L); // -1不启动。默认1min一次
        setMinEvictableIdleTimeMillis(10 * 60000L); // 可发呆的时间,10mins
        setTestWhileIdle(false); // 发呆过长移除的时候是否test一下先
    }
}
